package com.levi.task;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

@EnableScheduling
public class MQTask {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 定时每5秒查询一次本地消息表，把发送失败的消息重新发送一次
     */
    @Scheduled(cron = "0/5 * * * * ? ")
    public void sendMsg() {
        //查询数据库中本地消息冗余表，把发送失败的消息查询出来
        String msg = "发送失败的消息";
        rabbitTemplate.convertAndSend("","",msg);
    }
}
